using Unity.Burst;
using Unity.Collections;
using Unity.Entities;

namespace DOTS.DOD.LESSON7
{
    [BurstCompile]
    partial struct CubesMarchingEntityJob : IJobEntity
    {
        [ReadOnly] public float DeltaTime;
        public EntityCommandBuffer.ParallelWriter ECB_Parallel;

        void Execute([ChunkIndexInQuery] int chunkIndex, Entity entity, MarchingCubesAspect aspect)
        {
            if (aspect.IsNeedDestroy())
                ECB_Parallel.DestroyEntity(chunkIndex, entity);
            else
                aspect.Move(DeltaTime);
        }
    }
}